#include<bits/stdc++.h>
using namespace std;

int solution(int m, int n, string a[]) {
	int ans = 0;
	for (int i = 1; i < m; i++) {
		for (int j = 1; j < n; j++) {
			for (int k = 1; k <= m; k++) {
				if (j - k < 0 || j + k >= n || i - k < 0 || i + k >= m)
					break;

				if (a[i][j] == a[i - k][j - k] && a[i][j] == a[i - k][j + k] && a[i][j] == a[i + k][j - k] && a[i][j] == a[i + k][j + k])
					ans++;
				else
					break;
			}
		}
	}
	return ans;
}

int main() {
	int m, n;
	string a[150];
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i - 1];
	int ans = solution(n, m, a);
	cout << ans;
	return 0;
}

